<template>
	<view class="mygoods_info">
		<view class="status_text" v-if="data.status==0||data.status==1">
			审核中
		</view>
		<view class="status_texts" v-if="data.status==2">
			审核成功
		</view>
		<view class="status_textss" v-if="data.status==3">
			审核失败
		</view>
		<view class="type_name">
		 <view class="item" v-for="(value,index) in data.goods.types">
			 <view class="left" v-if="index==0">一级类目</view>
			 <view class="left" v-if="index==1">二级类目</view>
			 <view class="left" v-if="index==2">三级类目</view>
			 <view class="right">{{value.title}}</view>
		 </view>
		</view>
		
		<view class="goods_name">
			<view class="left">商品名称</view>
			<view class="right">{{data.goods.name}}</view>
		</view>
		<view class="goods_images">
			 <image v-for="value in data.goods.images"  :src="value" mode=""></image>
		</view>
		<view class="goods_info">
			<view class="left">
				<text class="fonts">出厂价</text>
				<text class="fonts">￥{{data.factory_price}}</text>
			</view>
			<view class="left">
				<text class="fonts">报价</text>
				<text class="fonts">￥{{data.quoted_price}}</text>
			</view>
		</view>
		
		<view class="goods_info">
			<view class="left">
				<text class="fonts">税金</text>
				<text class="fonts">￥{{data.taxes}}</text>
			</view>
			<view class="left">
				<text class="fonts">运费</text>
				<text class="fonts">￥{{data.shipping}}</text>
			</view>
		</view>
		
		<view class="goods_info">
			<view class="lefts">
				<text class="fonts">报价有效期</text>
				<text class="fonts">{{data.quoteddate}}</text>
			</view>
		</view>
		<view class="goods_text">
			<view class="items">
				<view class="left">起订量</view>
				<view class="right">{{data.num}}</view>
			</view>
			
			<view class="items">
				<view class="left">交货时间</view>
				<view class="right">{{data.num}}</view>
			</view>
			
			<view class="items">
				<view class="left">质保时间</view>
				<view class="right">{{data.warrantydate}}</view>
			</view>
		</view>
		
		<view class="bottom_btns">
			<view class="btn-cancel" @click="tabs()">未通过</view>
			<view class="btn-ok" @click="oks()">通过</view>
		</view>
		
		<view class="black_moban" v-show="showsss"></view>
		<view class="wuliu_top" v-show="showsss">
			 <view class="titles">
				<textarea v-model="reason" placeholder="请输入未通过原因" class="index-title"></textarea>
			 </view>
			<view class="center">
				<view class="left" @click="closess()">取消</view>
				<view class="right" @click="submitsss()">确认</view>
			</view>
		</view>
		
	</view>
</template>

<script>	

import {
		ajax
	} from '../../ajax.js';
	export default {
		data() {
		 return {
			firstNum:1,
			num:20,
			type:0,
			reason:'',
			id:'',
			showsss:false,
			data:{
				goods:{
					types:[]
				}
			},
		   }
		},
		onLoad(opt) {
			if(opt.id){
				this.id=opt.id
				this.getdetail()
			}
			
		},
		methods:{
			tabs(){
				this.showsss=true
			},
			oks(){
			let that =this
			let value=that.data
			
			if(that.reason==''){
				uni.showToast({
					title:'请输入未通过原因',
					duration: 1500,
					icon: 'none'
				});
			  return
			}
			ajax({
				url: 'goods/editGoodStatus',
				data: {
					token:uni.getStorageSync('token'),
					good_id: value.good_id,
					spec_id:value.spec_id,
					status:2,
					reason:''
				},
				header: {
					'content-type': 'application/json' //自定义请求头信息
				},
				method: 'POST',
				success: function(res) {
					console.log("token", res.data.data)
					if(res.data.code==1){
						uni.showToast({
							title: res.data.msg,
							duration: 1500,
							icon: 'none'
						});
						//this.showsss=false
					}else{
						uni.showToast({
							title: res.data.msg,
							duration: 1500,
							icon: 'none'
						});
					}
				},
				error: function() {
						
				}
				});
			},
			closess(){
				this.showsss=false
			},
			submitsss(){
				let that =this
				let valuess=that.data
				if(that.reason==''){
					uni.showToast({
						title:'请输入未通过原因',
						duration: 1500,
						icon: 'none'
					});
				  return
				}
				ajax({
					url: 'goods/editGoodStatus',
					data: {
						token:uni.getStorageSync('token'),
						good_id: valuess.good_id,
						spec_id:valuess.spec_id,
						status:3,
						reason:that.reason
					},
					header: {
						'content-type': 'application/json' //自定义请求头信息
					},
					method: 'POST',
					success: function(res) {
						console.log("token", res.data.data)
						if(res.data.code==1){
							uni.showToast({
								title: res.data.msg,
								duration: 1500,
								icon: 'none'
							});
							this.showsss=false
						}else{
							uni.showToast({
								title: res.data.msg,
								duration: 1500,
								icon: 'none'
							});
						}
				},
				error: function() {
						
				}
				});
			},
			getdetail(){
				let that = this
				let token = uni.getStorageSync('token')
				
				ajax({
					url: 'goods/getGood',
					data: {
						token: token,
						id: that.id,
						from:0
					},
					header: {
						'content-type': 'application/json' //自定义请求头信息
					},
					method: 'POST',
					success: function(res) {
						console.log("token", res.data.data.data)
						//res.data.data.data[0].status_text='已发货'
						res.data.data.status='1'
						that.data = res.data.data
						
					},
					error: function() {
							
					}
				});
			}
		}
	}
	
	
</script>

<style lang="scss">
	page{
		background-color: #F7F7F7;
	}
	.black_moban{
		width: 750rpx;
		height: 100%;
		background-color: rgba(0, 0, 0, 0.5);
		position: absolute;
		top: 0;
	}
	.wuliu_top{
		width: 620rpx;
		height: 207rpx;
		background-color: #FFFFFF;
		position: absolute;
		top: 401rpx;
		left: 65rpx;
		border-radius: 20rpx;
		.index-title{
			width: 96%;
			padding: 2%;
			height: 160rpx;
			overflow: hidden;
		 }
		.center{
			width: 100%;
			overflow: hidden;
			margin: 0rpx auto;
			
			.left{
				width: 50%;
				line-height: 90rpx;
				height: 90rpx;
				text-align: center;
				color: #333;
				background: #F7F7F7;
				float: left;
				border-bottom-left-radius:20rpx
			}
			.right{
				width: 50%;
				line-height: 90rpx;
				height: 90rpx;
				text-align: center;
				color: #FFFFFF;
				background: #FF7427;
				float: left;
				border-bottom-right-radius:20rpx
			}
		}
		.title{
			font-size: 32rpx;
			padding: 48rpx 0rpx 48rpx 0rpx;
			text-align: center;
		}
	}
 .mygoods_info{
	 width: 100%;
	 margin: 0rpx;
	 padding: 0rpx 0rpx;
	 .status_text{
		 width: 96%;
		 padding:10rpx 10rpx 10rpx 66rpx;
		 overflow: hidden;
		 color: #FF7427;
		 margin: 0rpx auto;
		 font-size: 30rpx;
		 background:url(../../static/clq-image/shenhezhong.png) no-repeat left #FFFFFF;
		 background-size: 36rpx;
		 background-position: 18rpx 18rpx;
		 line-height: 56rpx;
	 }
	 .status_texts{
	 		 width: 96%;
	 		 padding:10rpx 10rpx 10rpx 66rpx;
	 		 overflow: hidden;
	 		 color: #FF7427;
	 		 margin: 0rpx auto;
	 		 font-size: 30rpx;
	 		 background:url(../../static/clq-image/sccess.png) no-repeat left #FFFFFF;
	 		 background-size: 36rpx;
	 		 background-position: 18rpx 18rpx;
	 		 line-height: 56rpx;
	 }
	 .status_textss{
	 		 width: 96%;
	 		 padding:10rpx 10rpx 10rpx 66rpx;
	 		 overflow: hidden;
	 		 color: #FF7427;
	 		 margin: 0rpx auto;
	 		 font-size: 30rpx;
	 		 background:url(../../static/clq-image/badds.png) no-repeat left #FFFFFF;
	 		 background-size: 36rpx;
	 		 background-position: 18rpx 18rpx;
	 		 line-height: 56rpx;
	 }
	 .type_name{
		 width: 96%;
		 padding: 2%;
		 overflow: hidden;
		 font-size: 28rpx;
		 background-color: #FFFFFF;
		 .item{
			 width: 100%;
			 overflow: hidden;
			 margin: 0rpx auto;
			 line-height: 50rpx;
			 border-bottom: 2rpx solid #999999;
			 .left{
				 float: left;
				 width: 50%;
				 overflow: hidden;
				 font-size: 28rpx;
			 }
			 .right{
				 float: left;
				 width: 50%;
				 overflow: hidden;
				 font-size: 28rpx;
				 text-align: right;
			 }
		 }
		 .item:nth-child(3){
			 border-bottom: none;
		 }
	 }
	 .goods_name{
		 width: 94%;
		 overflow: hidden;
		 margin: 20rpx auto;
		 background-color: #FFFFFF;
		 padding: 3%;
		 font-size: 28rpx;
		 .left{
			 width: 20%;
			 float: left;
			 overflow: hidden;
			 font-size: 28rpx;
		 }
		 .right{
			 width:80%;
			 float: left;
			 text-align: right;
			 overflow: hidden;
			 font-size: 28rpx;
		 }
	 }
	 .goods_images{
		 width: 96%;
		 overflow: hidden;
		 padding: 2%;
		 margin: 0rpx auto;
		 image{
			 width: 208rpx;
			 height: 208rpx;
			 float: left;
			 margin-left: 18rpx;
		 }
	 }
	 .goods_info{
		 width: 100%;
		 overflow: hidden;
		 margin: 0rpx auto;
		 .left{
			 float: left;
			 width: 50%;
			 .fonts{
				 font-size: 28rpx;
				 margin-left: 38rpx;
				 overflow: hidden;
			  }
		 }
		 .lefts{
             float: left;
			 width: 60%;
			  .fonts{
				 font-size: 28rpx;
				 margin-left: 38rpx;
				 overflow: hidden;
			  }
		 }
	 }
	 .goods_text{
		  width: 96%;
		  padding: 2%;
		  overflow: hidden;
		  margin: 20rpx auto;
		  background: #FFFFFF;
		  .items{
			  overflow: hidden;
			  line-height: 72rpx;
			  margin: 0rpx auto;
			  border-bottom: 2rpx solid #f7f7f7;
			  .left{
				  float: left;
				  width: 50%;
				  font-size: 28rpx;
			  }
			  .right{
				 width:49%;
				 float: right;
				 text-align: right;
				 overflow: hidden;
				 font-size: 28rpx;
			  }
		  }
	 }
	 .bottom_btns{
		 width: 96%;
		 overflow: hidden;
		 margin-top: 60rpx;
		 padding: 2%;
		 .btn-cancel{
			 float: left;
			 margin-left: 5%;
			 width: 40%;
			 line-height: 68rpx;
			 height: 68rpx;
			 text-align: center;
			 font-size: 30rpx;
			 border-radius: 34rpx;
			 color: #FF7427;
			 border: 2rpx solid #FF7427;
			 
		 }
		 .btn-ok{
			 float: right;
			 margin-right: 5%;
			 width: 40%;
			 border-radius: 34rpx;
			 line-height: 68rpx;
			 height: 68rpx;
			 text-align: center;
			 font-size: 30rpx;
			 color: #FFFFFF;
			 background: #FF7427;
		 }
	 }
 }
</style>
